<?php
namespace pfp\lib {
    
    \defined( '_JEXEC' ) or die( 'Restricted access' );

    //******************************************************************************
    // SECTION 1 - GENERAL
    \define('DS', \DIRECTORY_SEPARATOR);

    //******************************************************************************
    // SECTION - Framework GENERAL
    $this->pfp->inDebugMode = \TRUE;
    $this->pfp->inProductionMode = !$this->pfp->inDebugMode();

    //******************************************************************************
    // SECTION - PHP RUNTIME GENERAL
    // 
    if ($this->pfp->inProductionMode()){
        \ini_set('display_startup_errors',0);
        \ini_set('display_errors', 0);
    } else {
        \ini_set('display_startup_errors',1);
        \ini_set('display_errors', 1);
    }
    \error_reporting(-1);
    \date_default_timezone_set('Europe/Athens');
    \setlocale(\LC_ALL,'es_ES.UTF-8');

    //******************************************************************************
    // SECTION - PATHS 
    $this->pfp->paths->entryPointPath               = $this->_pfp_entryPoint();
    $this->pfp->paths->eventsActionsFolderPath      = $this->pfp->paths->entryPointPath().'pfp/protected'.DS.'pfp_eventsActions'.DS;
    $this->pfp->paths->exceptionsHandlersFolderPath = $this->pfp->paths->entryPointPath().'pfp/protected'.DS.'pfp_exceptionsHandlers'.DS;
    $this->pfp->paths->librariesFolderPath          = $this->pfp->paths->entryPointPath().'pfp/protected'.DS.'pfp_libs'.DS;
    $this->pfp->paths->setupFolderPath              = $this->pfp->paths->entryPointPath().'pfp/protected'.DS.'pfp_setup'.DS;
    $this->pfp->paths->progsFolderPath              = $this->pfp->paths->entryPointPath().'pfp/protected'.DS.'pfp_progs'.DS;
    $this->pfp->paths->pluginsFolderPath            = $this->pfp->paths->entryPointPath().'pfp/protected'.DS.'pfp_plugins'.DS;
    $this->pfp->paths->publicFolderPath             = $this->pfp->paths->entryPointPath().'pfp'.DS.'public'.DS;

    //******************************************************************************
    // SECTION - PERMISSIONS MANAGER
    // 
    $this->pfp->permissionsManager->checks->namespace  = "pfp\\lib\\permsManager_checks\\";
    $this->pfp->permissionsManager->checks->folderName = "permsManager_checks";
    $this->pfp->permissionsManager->paths->checks_folderPath = $this->pfp->paths->librariesFolderPath().
            $this->pfp->permissionsManager->checks->folderName().DS;
    //******************************************************************************
    // SECTION - STORAGE
    // Description:
    // We can have different groups of tables in different databases, 
    // here, we have 6 groups: 
    // -- group main_server  : ??
    // -- group users        : 4 tables: tbl_users, tbl_users_data, tbl_users_groups, tbl_users_status
    // -- group sessions     : 1 table : tbl_sessions
    // -- group menus        : 4 tables: tbl_menus, tbl_menus_groups, tbl_menus_status, tbl_menus_types
    // -- group groups       : 2 tables: tbl_groups, tbl_groups_status
    // -- group resources    : 4 tables: tbl_resources, tbl_resources_groups, tbl_resources_status, tbl_resources_types 
    // 
    // All groups can be/exists/work on the same physical server or on different physical servers,
    // eg. we can have [group users] on a server in one country/town/office/etc., and all the other groups on another
    // physical server in another country/town/office/etc.
    // 
    // Default: All groups tables are/exists/work on the same physical server.
    //

    // group 0: Main server
    $this->pfp->storage->database->type          = "mysql";
    $this->pfp->storage->database->host          = "localhost";
    $this->pfp->storage->database->port          = "3306";
    $this->pfp->storage->database->name          = "pfp_01";
    $this->pfp->storage->database->username      = "pfp_01";
    $this->pfp->storage->database->user_password = "1234";
    $this->pfp->storage->database->table_prefix  = "tbl_";

    // group 1: groups tables
    $this->pfp->storage->groups_database->type               = $this->pfp->storage->database->type();
    $this->pfp->storage->groups_database->host               = $this->pfp->storage->database->host();
    $this->pfp->storage->groups_database->port               = $this->pfp->storage->database->port();
    $this->pfp->storage->groups_database->name               = $this->pfp->storage->database->name();
    $this->pfp->storage->groups_database->username           = $this->pfp->storage->database->username();
    $this->pfp->storage->groups_database->user_password      = $this->pfp->storage->database->user_password();
    $this->pfp->storage->groups_database->table_prefix       = $this->pfp->storage->database->table_prefix();
    $this->pfp->storage->groups_database->table_groups       = "groups";
    $this->pfp->storage->groups_database->table_groups_status= "groups_status";

    // group 2: users tables
    $this->pfp->storage->users_database->type               = $this->pfp->storage->database->type();
    $this->pfp->storage->users_database->host               = $this->pfp->storage->database->host();
    $this->pfp->storage->users_database->port               = $this->pfp->storage->database->port();
    $this->pfp->storage->users_database->name               = $this->pfp->storage->database->name();
    $this->pfp->storage->users_database->username           = $this->pfp->storage->database->username();
    $this->pfp->storage->users_database->user_password      = $this->pfp->storage->database->user_password();
    $this->pfp->storage->users_database->table_prefix       = $this->pfp->storage->database->table_prefix();
    $this->pfp->storage->users_database->table_users        = "users";
    $this->pfp->storage->users_database->table_users_data   = "users_data";
    $this->pfp->storage->users_database->table_users_groups = "users_groups";
    $this->pfp->storage->users_database->table_users_status = "users_status";

    // group 3: users_sessions tables
    $this->pfp->storage->users_sessions_database->type           = $this->pfp->storage->database->type();
    $this->pfp->storage->users_sessions_database->host           = $this->pfp->storage->database->host();
    $this->pfp->storage->users_sessions_database->port           = $this->pfp->storage->database->port();
    $this->pfp->storage->users_sessions_database->name           = $this->pfp->storage->database->name();
    $this->pfp->storage->users_sessions_database->username       = $this->pfp->storage->database->username();
    $this->pfp->storage->users_sessions_database->user_password  = $this->pfp->storage->database->user_password();
    $this->pfp->storage->users_sessions_database->table_prefix   = $this->pfp->storage->database->table_prefix();
    $this->pfp->storage->users_sessions_database->table_sessions = "sessions";

    // group 4: users_menus tables
    $this->pfp->storage->users_menus_database->type               = $this->pfp->storage->database->type();
    $this->pfp->storage->users_menus_database->host               = $this->pfp->storage->database->host();
    $this->pfp->storage->users_menus_database->port               = $this->pfp->storage->database->port();
    $this->pfp->storage->users_menus_database->name               = $this->pfp->storage->database->name();
    $this->pfp->storage->users_menus_database->username           = $this->pfp->storage->database->username();
    $this->pfp->storage->users_menus_database->user_password      = $this->pfp->storage->database->user_password();
    $this->pfp->storage->users_menus_database->table_prefix       = $this->pfp->storage->database->table_prefix();
    $this->pfp->storage->users_menus_database->table_menus        = "menus";
    $this->pfp->storage->users_menus_database->table_menus_groups = "menus_groups";
    $this->pfp->storage->users_menus_database->table_menus_status = "menus_status";
    $this->pfp->storage->users_menus_database->table_menus_types  = "menus_types";

    // group 5: users_resources tables
    $this->pfp->storage->users_resources_database->type                   = $this->pfp->storage->database->type();
    $this->pfp->storage->users_resources_database->host                   = $this->pfp->storage->database->host();
    $this->pfp->storage->users_resources_database->port                   = $this->pfp->storage->database->port();
    $this->pfp->storage->users_resources_database->name                   = $this->pfp->storage->database->name();
    $this->pfp->storage->users_resources_database->username               = $this->pfp->storage->database->username();
    $this->pfp->storage->users_resources_database->user_password          = $this->pfp->storage->database->user_password();
    $this->pfp->storage->users_resources_database->table_prefix           = $this->pfp->storage->database->table_prefix();
    $this->pfp->storage->users_resources_database->table_resources        = "resources";
    $this->pfp->storage->users_resources_database->table_resources_groups = "resources_groups";
    $this->pfp->storage->users_resources_database->table_resources_status = "resources_status";
    $this->pfp->storage->users_resources_database->table_resources_types  = "resources_types";

    //******************************************************************************
    // SECTION  - LOGS (LOGGER)
    $this->pfp->logger->storageTypes->file->path       = "";
    $this->pfp->logger->storageTypes->file->size_limit = "";
    $this->pfp->logger->storageTypes->file->rotate     = \TRUE;

    $this->pfp->logger->logWarnings                    = \TRUE;
            
    $this->pfp->logger->storageTypes->database->type                 = $this->pfp->storage->database->type();
    $this->pfp->logger->storageTypes->database->host                 = $this->pfp->storage->database->host();
    $this->pfp->logger->storageTypes->database->port                 = $this->pfp->storage->database->port();
    $this->pfp->logger->storageTypes->database->name                 = $this->pfp->storage->database->name();
    $this->pfp->logger->storageTypes->database->username             = $this->pfp->storage->database->username();
    $this->pfp->logger->storageTypes->database->user_password        = $this->pfp->storage->database->user_password();
    $this->pfp->logger->storageTypes->database->table_prefix         = $this->pfp->storage->database->table_prefix();
    $this->pfp->logger->storageTypes->database->table_framework_logs = "framework_logs";

    //******************************************************************************
    // SECTION - USER
    $this->pfp->users->rules->default_user_groupID   = 1; //this should be the Public Group in the db
    $this->pfp->users->rules->default_public_groupID = 1;
    $this->pfp->users->rules->guest_userID           = 1;
    $this->pfp->users->rules->remember_user          = \FALSE;

    $this->pfp->users->rules->username->minimum_length     = "4";
    $this->pfp->users->rules->username->maximum_length     = "32";
    $this->pfp->users->rules->username->allowed_characters = array(
        'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s',
        't','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L',
        'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0','1','2','3','4',
        '5','6','7','8','9','_','-',
    );
    // we can also do:
    //
    //$someVar = '';
    //$this->pfp->users->rules->username->function_validate = function(array $r=array()) use ($someVar){
    //    validate here and return results
    //}; 
    //
    //     OR
    //
    // we can use Events Actions to implem some validations
    //
    $this->pfp->users->rules->password->minimum_length     = "8";
    $this->pfp->users->rules->password->maximum_length     = "32";
    $this->pfp->users->rules->password->allowed_characters = array(
        'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s',
        't','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L',
        'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0','1','2','3','4',
        '5','6','7','8','9','_','-',
    );
    $this->pfp->users->rules->email_address->minimum_length     = "10";
    $this->pfp->users->rules->email_address->maximum_length     = "32";
    $this->pfp->users->rules->email_address->allowed_characters = array(
        'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s',
        't','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L',
        'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0','1','2','3','4',
        '5','6','7','8','9','_','-','@','.',
    );
    $this->pfp->users->rules->registration->sms_verification                 = \FALSE;
    $this->pfp->users->rules->registration->sms_verification_expires_after   = 60*24*3; // in minutes, default is 3 days
    $this->pfp->users->rules->registration->email_verification               = \TRUE;
    $this->pfp->users->rules->registration->email_verification_expires_after = 60*24*3; // in minutes, default is 3 days

    //******************************************************************************
    // SECTION - ROUTER

    $this->pfp->router->http->GET_request->request_field->Name   = 'req';
    $this->pfp->router->http->POST_request->request_field->Name  = 'req';
    
    /**
     * It must be a single character !!!!
     */
    $this->pfp->router->http->GET_request->separator             = "/";  
    
//    $this->pfp->router->http->GET_request->allowed_chars = array(
//        'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
//        'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
//        '0','1','2','3','4','5','6','7','8','9',
//        '_','=',
//    );
    
    $this->pfp->router->http->GET_request->program->name->allowed_chars = array(
        'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
        'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
        '0','1','2','3','4','5','6','7','8','9',
        '_',
    );
    $this->pfp->router->http->GET_request->program->name->min_length = 1;
    $this->pfp->router->http->GET_request->program->name->max_length = 128;

    $this->pfp->router->http->GET_request->controller->name->allowed_chars = array(
        'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
        'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
        '0','1','2','3','4','5','6','7','8','9',
        '_',
    );
    $this->pfp->router->http->GET_request->controller->name->min_length = 1;
    $this->pfp->router->http->GET_request->controller->name->max_length = 128;

    $this->pfp->router->http->GET_request->action->name->allowed_chars = array(
        'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
        'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
        '0','1','2','3','4','5','6','7','8','9',
        '_',
    );
    $this->pfp->router->http->GET_request->action->name->min_length = 1;
    $this->pfp->router->http->GET_request->action->name->max_length = 128;

    $this->pfp->router->http->GET_request->params->name->allowed_chars = array(
        'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
        'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
        '0','1','2','3','4','5','6','7','8','9',
        '_',
    );
    $this->pfp->router->http->GET_request->params->name->min_length = 1;
    $this->pfp->router->http->GET_request->params->name->max_length = 128;

    $this->pfp->router->http->GET_request->params->value->allowed_chars = array(
        'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
        'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
        '0','1','2','3','4','5','6','7','8','9',
        '_',
    );
    $this->pfp->router->http->GET_request->params->value->min_length = 1;
    $this->pfp->router->http->GET_request->params->value->max_length = 128;
    
    $this->pfp->router->http->GET_request->params->minimumNumberOfParameters = 0;
    $this->pfp->router->http->GET_request->params->maximumNumberOfParameters = 5;
    
    /**
     * It must be a single character !!!!
     */
    $this->pfp->router->http->GET_request->params->separator = ",";
    
    $this->pfp->router->http->GET_request->min_length = ($this->pfp->router->http->GET_request->program->name->min_length()+1
                                                        +$this->pfp->router->http->GET_request->controller->name->min_length()+1
                                                        +$this->pfp->router->http->GET_request->action->name->min_length()+1
                                                        +($this->pfp->router->http->GET_request->params->minimumNumberOfParameters()
                                                                *($this->pfp->router->http->GET_request->params->name->min_length()+1
                                                                   +$this->pfp->router->http->GET_request->params->value->min_length()+1)));
    
    $this->pfp->router->http->GET_request->max_length = ($this->pfp->router->http->GET_request->program->name->max_length()+1
                                                        +$this->pfp->router->http->GET_request->controller->name->max_length()+1
                                                        +$this->pfp->router->http->GET_request->action->name->max_length()+1
                                                        +($this->pfp->router->http->GET_request->params->maximumNumberOfParameters()
                                                                *($this->pfp->router->http->GET_request->params->name->max_length()+1
                                                                   +$this->pfp->router->http->GET_request->params->value->max_length()+1)));

    //******************************************************************************
    // SECTION  - SECURITY::ENCRYPTION
    $this->pfp->security->encryption->enabled = \FALSE;
    $this->pfp->security->encryption->key     = '';
    $this->pfp->security->encryption->method  = '';

    //******************************************************************************
    //******************************************************************************
    //******************************************************************************


    //******************************************************************************
    // SECTION 
    //$this->site->title          = 'Site Title';
    //$this->site->adminEmail     = 'zeageorge@';
    //$this->site->copyrightInfo  = 'Copyright &copy; 2012 by Zeakis George.<br/>All Rights Reserved.';
    //$this->site->url            = 'http://localhost/pfp/pfp/'; // Always provide a TRAILING SLASH (/) AFTER A PATH
    //
    //$this->site->paths->root_path = array(
    //    1=>array(
    //        'proto'=>'http://',
    //        'domain'=>'localhost',
    //        'ip_address'=>'127.0.0.1',
    //        'port'=>'80',
    //        'entryPoint'=>'index.php',
    //        'controller'=>'index.php',
    //        'controllers_default_action'=>'index',
    //    ),
    //    2=>array(
    //        'proto'=>'http://',
    //        'domain'=>'localhost',
    //        'ip_address'=>'192.168.0.100',
    //        'port'=>'80',
    //        'entryPoint'=>'index.php',
    //        'controller'=>'index.php',
    //        'controllers_default_action'=>'index',
    //    ),
    //);
    //$this->site->paths->css = array(
    //    'main'=>'mvc/public/css/',
    //);
    //$this->site->paths->img = array(
    //    'main'=>'mvc/public/images/',
    //);
    //$this->site->paths->js = array(
    //    'main'=>'mvc/public/js/',
    //);

    //******************************************************************************
    // SECTION 
    //$this->client->encryption->enabled = FALSE;
    //$this->client->encryption->key = '';
    //$this->client->encryption->method = '';

    // *****************************************************************************
    // SECTION  - TESTING...

    $someVar = '';
    $this->pfp->functions->test1 = function(array $r=array()) use ($someVar){

    }; 
}
?>